package com.huawei.appgallery.forum.option.post.view;

import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import o.azb;
import o.bqy;
import o.brd;
import o.bsp;
import o.byc.a;
import o.byc.c;
import o.byc.d;
import o.byc.f;
import o.byh;
import o.cjk;
import o.cjm;
import o.cjo;
import o.epw;

public class PostCardLinkView extends RelativeLayout {
    private String ˊ;
    private RelativeLayout ˋ;
    private Context ˎ;
    private byh ˏ;
    private TextView ॱ;

    public PostCardLinkView(Context context) {
        this(context, null);
    }

    public PostCardLinkView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public PostCardLinkView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ˎ = context;
        ॱ();
    }

    private void ॱ() {
        RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(getContext()).inflate(f.ˎ, this);
        this.ॱ = (TextView) relativeLayout.findViewById(d.ॱᐝ);
        this.ˋ = (RelativeLayout) relativeLayout.findViewById(d.ˎ);
        this.ˋ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ PostCardLinkView ˋ;

            {
                this.ˋ = r1;
            }

            public void onClick(View view) {
                this.ˋ.ॱ("app|" + this.ˋ.ˏ.ˋ());
                brd.ॱ.ˎ(bqy.ˋ().ˎ(), bqy.ˋ().ˎ(this.ˋ.ˎ), this.ˋ.ˏ.ˋ());
            }
        });
        if (epw.ˏ()) {
            this.ˋ.setBackground(this.ˎ.getResources().getDrawable(c.ˎ));
        } else {
            this.ˋ.setBackground(this.ˎ.getResources().getDrawable(c.ˋ));
        }
    }

    public void setCardLinkDate(byh o_byh) {
        this.ˏ = o_byh;
        if (this.ॱ != null) {
            String ॱ = this.ˏ.ॱ();
            this.ॱ.setText(ॱ);
            ˎ(ॱ);
        }
    }

    private void ˎ(String str) {
        int ॱ = azb.ॱ(this.ˎ);
        int ˏ = bsp.ˏ(this.ॱ, str);
        int ˊ = ((ॱ - (azb.ˊ(this.ˎ) * 2)) - (this.ˎ.getResources().getDimensionPixelSize(a.ʽ) * 3)) - this.ˎ.getResources().getDimensionPixelSize(a.ˊ);
        LayoutParams layoutParams = this.ˋ.getLayoutParams();
        if (ˏ >= ˊ) {
            layoutParams.width = (ॱ - (azb.ˊ(this.ˎ) * 2)) - 4;
        } else {
            layoutParams.width = -2;
        }
        this.ˋ.setLayoutParams(layoutParams);
    }

    public byh ˏ() {
        return this.ˏ;
    }

    public void setTrace(String str) {
        this.ˊ = str;
    }

    private void ॱ(String str) {
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        appDetailActivityProtocol.ˏ(new Request(str, this.ˊ));
        cjk.ˎ().ˋ(this.ˎ, new cjm("appdetail.activity", appDetailActivityProtocol));
    }

    public void setRootLayoutClickable(boolean z) {
        this.ˋ.setClickable(z);
    }

    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.ˏ != null) {
            ˎ(this.ˏ.ॱ());
        }
    }

    public TextView ˊ() {
        return this.ॱ;
    }

    public void setLinkText(TextView textView) {
        this.ॱ = textView;
    }
}
